package com.pro.common.api.user.file.model.db;

import com.pro.common.api.CommonConst;
import com.pro.common.api.model.BaseUserIdModel;
import com.pro.common.api.model.auth.IUserDataClass;
import com.pro.common.api.user.file.enums.EnumFileStatus;
import com.pro.framework.javatodb.annotation.JTDField;
import com.pro.framework.javatodb.annotation.JTDTable;
import com.pro.framework.javatodb.constant.JTDConst;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "文件节点对应文件信息")
@JTDTable(sequences = {
        "KEY `idx_userId_deleted_createTime` (`user_id`,`deleted`,`create_time`)",
        "UNIQUE KEY `uk_fileNodeId` (`file_node_id`)",
        "KEY `idx_fileHash_userId` (`file_hash`, `user_id`)",
        "KEY `idx_storageKey` (`storage_key`)",
}, module = CommonConst.Modules.userFile, entityId = 30002)
public class UserFile extends BaseUserIdModel implements IUserDataClass {

    @Schema(description = "文件节点ID")
    private Long fileNodeId;  // 与 FileNode.id 关联

    @Schema(description = "存储对象Key")
    private String storageKey;

    @Schema(description = "对象存储返回的 ETag（用于并发控制/存储校验，不一定等于 MD5）")
    private String etag;

    @Schema(description = "文件内容哈希（MD5/SHA256），用于秒传、去重、完整性校验")
    private String fileHash;

    @Schema(description = "文件状态")
    @JTDField(type = JTDConst.EnumFieldType.int_, defaultValue = "0", entityClassKey = "value")
    private EnumFileStatus status;

    @Schema(description = "存储桶")
    private String bucket;
}
